<?php
/*
	Sponsor Manager (html.php file)
    Copyright (C) <Fri Feb 08 21:39:08 CET 2008>  Marcos Ramírez <marcosramirez@gmail.com>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

 */
class HTML {
	private static $author;
	private static $title;
	private static $error;
	private static $info;
	private static $errorCont;
	private static $infoCont;
	private static $css;
	
	function __construct() {
		$this->author='Marcos Ramírez';
		$this->crap='Blah, Blah';
		$this->title='Sponsor Manager';
	}
	
	function addJSFile($file) {
		global $Cfg;
		$url=str_replace('//', '/', $url);
		$this->headContent.='<script src="'.$Cfg['Sys']['webDir'].'templates/'.$Cfg['Sys']['defaultTemplate'].'/js/'.$file.'" type="text/javascript"></script>';
	}
	
	function addCSSFile ($file) {
		global $Cfg;
		$this->css.='<link rel="stylesheet" type="text/css" media="screen" href="'.$Cfg['Sys']['webDir'].'templates/'.$Cfg['Sys']['defaultTemplate'].'/css/'.$file.'" />'."\n";
	}
	
	function header () {
		global $Cfg;
		echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
		<html>
		<head>
		<title>'.$this->title.'</title>
		<link rel="stylesheet" type="text/css" media="screen" href="'.$Cfg['Sys']['webDir'].'templates/'.$Cfg['Sys']['defaultTemplate'].'/css/main.css" />
		'.$this->css.'
		<script src="'.$Cfg['Sys']['webDir'].'templates/'.$Cfg['Sys']['defaultTemplate'].'/js/jquery.js" type="text/javascript"></script>
		<script src="'.$Cfg['Sys']['webDir'].'templates/'.$Cfg['Sys']['defaultTemplate'].'/js/main.js.php" type="text/javascript"></script>
		'.$this->headContent.'
		</head>
		<body>
		<div id="container">
		<div id="loading">'._('Loading.. please, wait.').'</div>
		<div id="logo"></div>
'.$this->showMenu().'
		<div id="spacer"></div>
		<div id="showError">'.$this->showErrorInfo(error).'</div>
		<div id="infoLine">'.$this->showErrorInfo(info).'</div>
		
		';
		
	}
	
	function showMenu () {
		global $Cfg;
		if ($_SESSION['loggedin']!=1)
			return '';
		return '		<div class="blue">
				<div id="slatenav">
				<ul>
				<li>
					<a href="'.$Cfg['Sys']['webDir'].'" class="current">'._('Resume').'</a>
				</li>

				<li>
					<a href="'.$Cfg['Sys']['webDir'].'?section=users">'._('Users').'</a>
				</li>
				<li>
					<a href="'.$Cfg['Sys']['webDir'].'?section=domains">'._('My Domains/IPs').'</a>
				</li>
				
				<li>
					<a href="'.$Cfg['Sys']['webDir'].'?section=Sponsors">'._('Sponsors').'</a>
				</li>
				<li>
					<a href="'.$Cfg['Sys']['webDir'].'?section=Categories">'._('Categories').'</a>
				</li>

				
				<li>
					<a href="'.$Cfg['Sys']['webDir'].'?section=Promotions">'._('Promotions').'</a>
				</li>
				
				<li>
					<a href="'.$Cfg['Sys']['webDir'].'?section=DevelopersTeam">'._('SM Developers Team').'</a>
				</li>

				<li>
					<a href="'.$Cfg['Sys']['webDir'].'?section=HELP">'._('Help').'</a>
				</li>
								
				</ul>
				</div>
			</div>';
	}
	
	function footer () {
		echo '
		<div id="spacer"></div>
		<div id="footer">
		&copy; 2.008 The Sponsor Manager Developer Team
		</div>
		</div> <!-- Close container div-->
		</body>
		</html>';
	}
	
	// Set the title (overwrites)
	function setTitle ($title) {
		$this->title=$title;
	}
	
	//Add the tittle (appends/concat)
	function addTitle ($title) {
		$this->title.=$title;
	}
	
	//Add the error string (append)
	function addError ($error) {
		$this->errorCont++;
		if ($Cfg['Sys']['useULInErrorInfo']==1)
			$this->error.="<li>$error</li>";
		else
			$this->error.=$error;
	}
	
	//Set the error string (overwrites)
	function setError ($error) {
		$this->error=$error;
	}

	function setInfo ($info) {
		$this->info=$info;
	}
	
	function addInfo ($info) {
		global $Cfg;
		$this->infoCont++;
		if ($Cfg['Sys']['useULInErrorInfo']==1)
			$this->info.="<li>$info</li>";
		else 
			$this->info.="<$info";
	}
	
	function showErrorInfo ($type='error') {
		if ($this->errorCont==0 && $this->infoCont==0)
			return $this->type;
		
		global $Cfg;
		if ($Cfg['Sys']['useULInErrorInfo']==1) {
			$list=$this->$type;
			return $this->$type='<ul>'.$list.'</ul>';
		} else {
			return $this->$type;
		}
	}
}
?>